{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Not updating worker name since `setproctitle` is not installed. Install this with `pip install setproctitle` (or ray[debug]) to enable monitoring of worker processes.\n",
      "Process STDOUT and STDERR is being redirected to /tmp/ray/session_2019-04-23_20-30-55_49959/logs.\n",
      "Waiting for redis server at 127.0.0.1:59023 to respond...\n",
      "Waiting for redis server at 127.0.0.1:62342 to respond...\n",
      "Starting Redis shard with 10.0 GB max memory.\n",
      "Warning: Capping object memory store to 20.0GB. To increase this further, specify `object_store_memory` when calling ray.init() or ray start.\n",
      "WARNING: object_store_memory is not verified when plasma_directory is set.\n",
      "Starting the Plasma object store with 20.0 GB memory using /workspaces/sefik/temp.\n",
      "\n",
      "======================================================================\n",
      "View the web UI at http://localhost:8888/notebooks/ray_ui.ipynb?token=47981aa474947d8c01ed1e65ceacb6b993a93cd0747dc504\n",
      "======================================================================\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'node_ip_address': None,\n",
       " 'redis_address': '172.17.0.2:59023',\n",
       " 'object_store_address': '/tmp/ray/session_2019-04-23_20-30-55_49959/sockets/plasma_store',\n",
       " 'webui_url': 'http://localhost:8888/notebooks/ray_ui.ipynb?token=47981aa474947d8c01ed1e65ceacb6b993a93cd0747dc504',\n",
       " 'raylet_socket_name': '/tmp/ray/session_2019-04-23_20-30-55_49959/sockets/raylet'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import ray\n",
    "ray.init(plasma_directory=\"/workspaces/sefik/temp\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Not updating worker name since `setproctitle` is not installed. Install this with `pip install setproctitle` (or ray[debug]) to enable monitoring of worker processes.\n",
      "Calling ray.init() again after it has already been called.\n"
     ]
    }
   ],
   "source": [
    "import modin.pandas as modin"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.8997976779937744  seconds in Modin\n",
      "Lasts  7.41630744934082  seconds in Pandas\n",
      "Modin is  8.242194474069462  times faster than Pandas\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df = modin.read_csv(\"/workspaces/sefik/train.csv\")\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df = pd.read_csv(\"/workspaces/sefik/train.csv\")\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.25974059104919434  seconds in Modin\n",
      "Lasts  0.0024178028106689453  seconds in Pandas\n",
      "Pandas is  107.4283601222759  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df['var_0'].std()\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df['var_0'].std()\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.25777673721313477  seconds in Modin\n",
      "Lasts  0.0016782283782958984  seconds in Pandas\n",
      "Pandas is  153.60051143628357  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df['var_0'].max()\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df['var_0'].max()\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.25787782669067383  seconds in Modin\n",
      "Lasts  0.0016412734985351562  seconds in Pandas\n",
      "Pandas is  157.1205694363742  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df['var_0'].min()\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df['var_0'].min()\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "UserWarning: `to_csv` defaulting to pandas implementation.\n",
      "To request implementation, send an email to feature_requests@modin.org.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  49.20240926742554  seconds in Modin\n",
      "Lasts  47.45608687400818  seconds in Pandas\n",
      "Pandas is  1.036798701883147  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df.to_csv(\"train_modin.csv\")\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df.to_csv(\"train_pandas.csv\")\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  1.1986660957336426  seconds in Modin\n",
      "Lasts  0.2957463264465332  seconds in Modin\n",
      "Modin is  160.46213470917812  times faster than Pandas\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df.merge(modin_df, left_index=True, right_index=True)\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df.merge(pandas_df, left_index=True, right_index=True)\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.2640244960784912  seconds in Modin\n",
      "Lasts  0.00182342529296875  seconds in Pandas\n",
      "Pandas is  144.79589435146443  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df['var_0'].mean()\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df['var_0'].mean()\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.2583589553833008  seconds in Modin\n",
      "Lasts  0.0014247894287109375  seconds in Pandas\n",
      "Pandas is  181.33132530120483  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df['var_0'].sum()\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df['var_0'].sum()\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.26265549659729004  seconds in Modin\n",
      "Lasts  0.0002224445343017578  seconds in Pandas\n",
      "Pandas is  1180.7684887459807  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df['var_0'].head()\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df['var_0'].head()\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lasts  0.0034551620483398438  seconds in Modin\n",
      "Lasts  0.0006339550018310547  seconds in Pandas\n",
      "Pandas is  5.450169236555096  times faster than Modin\n"
     ]
    }
   ],
   "source": [
    "tic = time.time()\n",
    "modin_df.groupby(['var_0'])\n",
    "toc = time.time()\n",
    "modin_time = toc-tic\n",
    "print(\"Lasts \",modin_time,\" seconds in Modin\")\n",
    "#----------------------------\n",
    "tic = time.time()\n",
    "pandas_df.groupby(['var_0'])\n",
    "toc = time.time()\n",
    "pandas_time = toc - tic\n",
    "print(\"Lasts \",pandas_time,\" seconds in Pandas\")\n",
    "#----------------------------\n",
    "if pandas_time > modin_time:\n",
    "    print(\"Modin is \",pandas_time / modin_time,\" times faster than Pandas\")\n",
    "else:\n",
    "    print(\"Pandas is \",modin_time / pandas_time,\" times faster than Modin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
